<template>
    <div class="mycontents">
        <div class="app-header">
            <h1 class="app-title">蓝色商城</h1>
            <p class="app-subtitle">拾星藏岁，甄选心欢</p>
        </div>
        <!-- 上方菜单栏 -->
         <div class="tab-container">
            <ul class="tab-header">
                <router-link v-for="tab in tabs"
                :key="tab.name"
                :to="{name:tab.name}"
                custom
                v-slot="{navigate,isActive}"
                >
                <li class="tab-item"
                   :class="{active:isActive}"
                   @click="navigate">
                    <span class="tab-ico">{{tab.ico}}</span>
                    <span class="tab-text">{{tab.text}}</span>
                </li>
                </router-link> 
            </ul>

         <!-- 主要内容区域 -->
          <div class="content">
            <router-view></router-view>
          </div>
        </div>
    </div>
</template>

<script>
import { computed } from 'vue'
import { useStore } from 'vuex'

export default {
    name: 'mycontents',
    setup() {
        const store = useStore()
        
        // 标签页配置
        const tabs = [
            { name: 'homemade', ico: '🎉', text: '自制周边' },
            { name: 'official', ico: '🎏', text: '官方商区' },
            { name: 'mycollection', ico: '👑', text: '我的购物车' },
            { name: 'myorder', ico: '🛍️', text: '我的订单' }
        ]
        
        // 使用Vuex获取数据
        const Movies = computed(() => store.getters.allProducts)
        const mycollection = computed(() => store.getters.cartItems)
        
        return {
            tabs,
            mycollection,
            Movies
        }
    }
}
</script>

<style scoped>
/* 应用主容器 */
.mycontents {
    min-height: 100vh;
    background: #f0f8ff;
    padding: 20px;
}

/* 应用头部 */
.app-header {
    text-align: center;
    margin-bottom: 40px;
    color: #2c3e50;
}

.app-title {
    font-size: 2.8rem;
    font-weight: 600;
    margin: 0 0 15px 0;
    color: #1976d2;
    letter-spacing: -0.5px;
}

.app-subtitle {
    font-size: 1.1rem;
    color: #5a6c7d;
    margin: 0;
    font-weight: 400;
    opacity: 0.8;
}

/* 选项卡容器 */
.tab-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(25, 118, 210, 0.08);
    border: 1px solid #e3f2fd;
    overflow: hidden;
    margin: 0 auto;
    max-width: 1200px;
    position: relative;
}
/* 选项卡标题 */
.tab-header {
    display: flex;
    justify-content: center;
    background: #e3f2fd;
    padding: 0;
    position: relative;
    list-style: none;
    margin: 0;
    border-radius: 0;
    border-bottom: 1px solid #bbdefb;
}
         
.tab-item {
    flex: 1;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.tab-item {
    text-decoration: none;
    padding: 18px 15px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #5a6c7d;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.tab-item:hover {
    color: #1976d2;
    background: rgba(25, 118, 210, 0.05);
}

.tab-item.active {
    color: #1976d2;
    font-weight: 600;
    background: rgba(25, 118, 210, 0.08);
    border-bottom-color: #1976d2;
}

.tab-ico {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 4px;
    opacity: 0.8;
}

.tab-text {
    font-size: 0.85rem;
    white-space: nowrap;
    letter-spacing: 0.3px;
}
/* 内容区域 */
.content {
    padding: 30px;
    min-height: 500px;
    background: #ffffff;
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .mycontents {
        padding: 15px;
    }
    
    .app-title {
        font-size: 2.2rem;
    }
    
    .app-subtitle {
        font-size: 1rem;
    }
    
    .tab-item {
        padding: 14px 8px;
        font-size: 0.85rem;
    }
    
    .tab-ico {
        font-size: 1.2rem;
    }
    
    .content {
        padding: 20px;
        min-height: 400px;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.8rem;
    }
    
    .tab-header {
        flex-wrap: wrap;
    }
    
    .tab-item {
        flex: 1 1 50%;
        min-width: 120px;
        padding: 12px 6px;
        font-size: 0.8rem;
    }
    
    .content {
        padding: 15px;
    }
}
</style>